package cn.tedu._05mvcboot02.common.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResuli {
    private Integer state;
    private String message;
    private Object data;

    public JsonResuli(Statuscode statuscode) {
        this.state = statuscode.getState();
        this.message = statuscode.getMessage();
    }

    public JsonResuli(Statuscode statuscode, Object data) {
        this.state = statuscode.getState();
        this.message = statuscode.getMessage();
        this.data = data;
    }

    public static JsonResuli ok(Object data) {
        return new JsonResuli(Statuscode.OPERATION_SUCCESS, data);

    }

    public static JsonResuli ok() {
        return ok(null);
    }
}